﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //根据内容自动调整大小
            this.textBox1.AutoSize = true;
        }
        protected override void OnLayout(LayoutEventArgs levent)
        {
            // 1 调用父类的OnLayout()，不是必需的
            base.OnLayout(levent);

            // 2 获取窗口大小 ClientSize（仅客户区，不含标题栏）
            int w = this.ClientSize.Width;
            int h = this.ClientSize.Height;

            // 3 计算每一个控件的位置和大小
            int yoff = 0;

            yoff = 4;
            this.textBox1.Location = new Point(0, yoff);
            this.textBox1.Size = new Size(w - 80, 30);
            this.button1.Location = new Point(w - 80, yoff);
            this.button1.Size = new Size(80, 30);
            yoff += 30; // 第一行的高度
            yoff += 4; // 间隔
            this.pictureBox1.Location = new Point(0, yoff);
            this.pictureBox1.Size = new Size(w, h - yoff - 4);

        }
    }
}
